//
//  APHomeUserView.m
//  AqualPolo
//
//  Created by dong on 2024/5/13.
//

#import "APHomeUserView.h"

@implementation APHomeUserView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        UIView *borderView = [[UIView alloc] init];
        borderView.layer.cornerRadius = 8;
        borderView.layer.masksToBounds = true;
        [borderView setGradientBackgroundWithColors:@[LYRGBColor(87, 61, 255),LYRGBAColor(52, 37, 153,0)] locations:@[@0,@1] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        [self addSubview:borderView];
        [borderView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(49);
            make.left.right.bottom.equalTo(self);
        }];
        _contentView = [[UIView alloc] init];
        _contentView.layer.cornerRadius = 8;
        _contentView.layer.masksToBounds = true;
        [_contentView setGradientBackgroundWithColors:@[LYRGBColor(19, 78, 104),LYRGBColor(25, 15, 85)] locations:@[@0,@1] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        [borderView addSubview:_contentView];
        [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(borderView).offset(2);
            make.bottom.equalTo(self);
            make.left.equalTo(borderView).offset(2);
            make.right.equalTo(borderView).offset(-2);
        }];
        
        _avatarImageView = [[UIImageView alloc] init];
        _avatarImageView.layer.cornerRadius = 41;
        _avatarImageView.layer.masksToBounds = true;
        [self addSubview:_avatarImageView];
        [_avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self);
            make.centerX.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(82, 82));
        }];
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.font = [UIFont systemFontOfSize:18];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        [_contentView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_avatarImageView.mas_bottom).offset(12);
            make.height.mas_equalTo(18);
            make.centerX.equalTo(self.contentView).offset(-16);
        }];
        
        _ballImageView = [[UIImageView alloc] init];
        _ballImageView.image = [UIImage imageNamed:@"ball_1"];
        [self.contentView addSubview:_ballImageView];
        [_ballImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_nameLabel.mas_right).offset(8);
            make.centerY.equalTo(_nameLabel);
            make.size.mas_equalTo(CGSizeMake(24, 24));
        }];
        
        _ballNameLabel = [[UILabel alloc] init];
        _ballNameLabel.textColor = LYRGBColor(121, 255, 213);
        _ballNameLabel.font = [LYFont fontWithSize:18 fontName:LYFontNamepfb];
        _ballNameLabel.textAlignment = NSTextAlignmentCenter;
        [_contentView addSubview:_ballNameLabel];
        [_ballNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_ballImageView.mas_bottom).offset(17);
            make.left.right.equalTo(self);
        }];
        
        _tipLabel = [[UILabel alloc] init];
        _tipLabel.numberOfLines = 0;
        _tipLabel.textColor = LYRGBAColor(255, 255, 255, 0.8);
        _tipLabel.font = [LYFont fontWithSize:15 fontName:LYFontNamepfr];
        _tipLabel.numberOfLines = 2;
        _tipLabel.textAlignment = NSTextAlignmentCenter;
        _tipLabel.text = @"Tip：Click on it to view the unlocking conditions.";
        [_contentView addSubview:_tipLabel];
        [_tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_ballNameLabel.mas_bottom).offset(16);
            make.left.equalTo(_contentView).offset(35);
            make.right.equalTo(_contentView).offset(-35);
        }];
        
    }
    return self;
}

@end
